{% extends "entrenadores/base.html" %}

{% block title %}Entrenadores - Inicio{% endblock %}

{% block extrahead %}
    {% load static %}
    {% get_static_prefix as STATIC_PREFIX %}
    
    <link rel="stylesheet" type="text/css" media="screen" href="{{ STATIC_PREFIX }}css/jquery/ui/jquery-ui-1.8.16.custom.css" />
    <link rel="stylesheet" type="text/css" media="screen" href="{{ STATIC_PREFIX }}css/jquery/ui/jquery.ui.jqgrid.css" />
    <script src="{{ STATIC_PREFIX }}js/jquery/jquery-1.7.min.js" type="text/javascript"></script>
    <script src="{{ STATIC_PREFIX }}js/jquery/jqGrid/i18n/grid.locale-es.js" type="text/javascript"></script>
    <script src="{{ STATIC_PREFIX }}js/jquery/jqGrid/jquery.jqGrid.js" type="text/javascript"></script>
    <script src="{{ STATIC_PREFIX }}js/common.js" type="text/javascript"></script>
    <script>
        $(document).ready(function() {
            $.getJSON("{% if not todos %}{% url entrenadores_activos_grid_config %}{% else %}{% url entrenadores_grid_config %}{% endif %}", 
            //$.getJSON("{% url entrenadores_activos_grid_config %}", function(data){
            function(data){
                data['sortname'] = 'apellidos',
                data["colNames"] = ['Id',{% if todos %}'Activo',{% endif %}'Nombres', 'Apellidos'];
                $("#mygrid")
                .jqGrid(data)
                .navGrid('#pager', 
                    {add: false, edit: false, del: false, view: false},
                    {}, // edit options
                    {}, // add options
                    {}, // del options 
                    {multipleSearch:true, closeOnEscape:true, drag:true, closeAfterSearch: true}, // search options 
                    {} // view options 
                );
                jQuery("#mygrid").jqGrid('navGrid',"#pager").jqGrid('navButtonAdd',"#pager",{caption:"Editar", buttonicon:"ui-icon-newwin", onClickButton:(function(event) {llamar_formulario('/entrenadores/editar/','')}), position:'first' ,title:"Editar"});
                jQuery("#mygrid").jqGrid('navGrid',"#pager").jqGrid('navButtonAdd',"#pager",{caption:"Ver", buttonicon:"ui-icon-newwin", onClickButton:(function(event) {llamar_formulario('/entrenadores/ver/','')}), position:'first' ,title:"Ver"});
            });
        })
    </script> 
{% endblock %}

{% block breadcrumb %} <a href="/">Inicio</a> > {% if not todos %}Entrenadores{% else %} <a href='/entrenadores/'>Entrenadores activos</a> > Todos los entrenadores {% endif %} {% endblock %}

{% block content %}
<div class='buttons' align='right'>
    {% if todos %}
        <input type='submit' value='Regresar' onclick="document.location = '../';">
    {% endif %}
    
    <input type='submit' value='Agregar entrenador' onclick="document.location = '/entrenadores/crear/';">
    {% if not todos %}<input type='submit' value='Mostrar todos' onclick="document.location = '/entrenadores/todos/';"> {% endif %}
</div>

<div class="main">
    <div id="jqgrid">
        <table id="mygrid"></table>
        <div id="pager"></div>
    </div>
</div>
{% endblock content %}

